<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:cc="http://java.sun.com/jsf/composite"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:pe="http://primefaces.org/ui/extensions"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <!-- INTERFACE -->
    <cc:interface>
    </cc:interface>

    <!-- IMPLEMENTATION -->
    <cc:implementation>
        <p:panel id="tab"  >
            <h:panelGroup style="font-weight: bold;">
                <h:outputLabel value="History of : "/>
                <h:outputLabel value="#{pharmacyController.pharmacyItem.name}"/>
            </h:panelGroup><br/><br/>
            <h:panelGrid columns="5" style="min-width: 100%;">
                <h:outputLabel value="From Date"/>
                <p:calendar id="frmDate" value="#{pharmacyController.fromDate}" 
                            navigator="true"  pattern="dd MMMM yyyy HH:mm:ss" >
                    <!--<f:ajax event="dateSelect" execute="@this toDate" render="tab"/>-->
                </p:calendar>

                <h:outputLabel value="To Date"/>
                <p:calendar id="toDate" value="#{pharmacyController.toDate}" navigator="true" pattern="dd MMMM yyyy HH:mm:ss" >
                    <!--<f:ajax event="dateSelect" execute="@this toDate" render="tab"/>-->
                </p:calendar>
                <p:commandButton update=":#{p:component('grn')} :#{p:component('po')} :#{p:component('dp')} :#{p:component ('depIssue')}" 
                                 action="#{pharmacyController.createTable()}" value="View Detail"/>
            </h:panelGrid>
            <p:tabView  style="min-height: 250px;"   activeIndex="0" >
                <p:tab   title="Stock"    >
                    <p:dataTable styleClass="noBorder" value="#{pharmacyController.institutionStocks}" var="ins">
                        <p:columnGroup type="header">
                            <p:row>
                                <p:column >
                                    <f:facet name="header">
                                        Department Name
                                    </f:facet>
                                </p:column>
                                <p:column >
                                    <f:facet name="header">
                                        QTY
                                    </f:facet>
                                </p:column>
                            </p:row>
                        </p:columnGroup>
                        <p:subTable  value="#{ins.depatmentStocks}" var="dep">
                            <f:facet name="header">
                                #{ins.institution.name}
                            </f:facet>
                            <p:column>
                                #{dep.department.name}
                            </p:column>
                            <p:column style="text-align: right;">
                                <h:outputLabel value="#{dep.stock}">       
                                    <f:convertNumber integerOnly="true" />
                                </h:outputLabel> 
                            </p:column>
                            <p:columnGroup type="footer">
                                <p:row>
                                    <p:column footerText="Total Stock"></p:column>
                                    <p:column style="text-align: right;" footerText="#{ins.institutionTotal}">
                                        <f:facet name="footer">
                                            <h:outputLabel value="#{ins.institutionTotal}">
                                                <f:convertNumber integerOnly="true" />
                                            </h:outputLabel>
                                        </f:facet>
                                    </p:column>
                                </p:row>
                            </p:columnGroup>
                        </p:subTable>  
                        <p:columnGroup type="footer">
                            <p:row>
                                <p:column>
                                    <f:facet name="footer">
                                        Total Institution Stock
                                    </f:facet>
                                </p:column>
                                <p:column style="text-align: right;">
                                    <f:facet name="footer">
                                        <h:outputLabel id="grantTotal" value="#{pharmacyController.grantStock}">
                                            <f:convertNumber integerOnly="true" />
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>
                            </p:row>
                        </p:columnGroup>

                    </p:dataTable>                
                </p:tab>

                <p:tab   title="Sale"    >
                    <p:dataTable styleClass="noBorder" value="#{pharmacyController.institutionSales}" var="ins">
                        <p:columnGroup type="header">
                            <p:row>
                                <p:column >
                                    <f:facet name="header">
                                        Department Name
                                    </f:facet>
                                </p:column>
                                <p:column >
                                    <f:facet name="header">
                                        QTY
                                    </f:facet>
                                </p:column>
                                <p:column >
                                    <f:facet name="header">
                                        Value
                                    </f:facet>
                                </p:column>
                            </p:row>
                        </p:columnGroup>
                        <p:subTable  value="#{ins.departmentSales}" var="dep">
                            <f:facet name="header">
                                #{ins.institution.name}
                            </f:facet>
                            <p:column>
                                #{dep.department.name}
                            </p:column>
                            <p:column style="text-align: right;">
                                <h:outputLabel value="#{dep.saleQty}">   
                                    <f:convertNumber integerOnly="true" />
                                </h:outputLabel> 
                            </p:column>
                            <p:column style="text-align: right;">
                                <h:outputLabel value="#{dep.saleValue}">  
                                    <f:convertNumber pattern="#,##0.00" />
                                </h:outputLabel> 
                            </p:column>
                            <p:columnGroup type="footer">
                                <p:row>
                                    <p:column footerText="Total "></p:column>
                                    <p:column style="text-align: right;" footerText="#{ins.institutionQty}">
                                        <f:facet name="footer">
                                            <h:outputLabel value="#{ins.institutionQty}">
                                                <f:convertNumber integerOnly="true" />
                                            </h:outputLabel>
                                        </f:facet>
                                    </p:column>
                                    <p:column style="text-align: right;" footerText="#{ins.institutionValue}">
                                        <f:facet name="footer">
                                            <h:outputLabel value="#{ins.institutionValue}">
                                                <f:convertNumber  pattern="#,##0.00" />
                                            </h:outputLabel>
                                        </f:facet>
                                    </p:column>
                                </p:row>
                            </p:columnGroup>
                        </p:subTable>  
                        <p:columnGroup type="footer">
                            <p:row>
                                <p:column>
                                    <f:facet name="footer">
                                        Total Institution
                                    </f:facet>
                                </p:column>
                                <p:column style="text-align: right;">
                                    <f:facet name="footer">
                                        <h:outputLabel  value="#{pharmacyController.grantSaleQty}">   
                                            <f:convertNumber integerOnly="true" />
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>
                                <p:column style="text-align: right;">
                                    <f:facet name="footer">
                                        <h:outputLabel  value="#{pharmacyController.grantSaleValue}">
                                            <f:convertNumber  pattern="#,##0.00" />
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>
                            </p:row>
                        </p:columnGroup>

                    </p:dataTable>                
                </p:tab>

                <p:tab   title="Sale BillItem"    >
                    <p:commandButton ajax="false" value="Excel" styleClass="noPrintButton" style="float: right;" action="#{pharmacyController.createTable()}" >
                        <pe:exporter type="xlsx" target="tbl" fileName="Category_report"  />
                    </p:commandButton>
                    <p:dataTable id="tbl" styleClass="noBorder" value="#{pharmacyController.grns}" var="bi">
                        <p:column >
                            <f:facet name="header">
                                Ins Id
                            </f:facet>
                            <p:outputLabel value="#{bi.bill.insId}" />
                        </p:column>
                        <p:column >
                            <f:facet name="header">
                                deptId
                            </f:facet>
                            <p:outputLabel value="#{bi.bill.deptId}" />
                        </p:column>
                        <p:column >
                            <f:facet name="header">
                                department
                            </f:facet>
                            <p:outputLabel value="#{bi.bill.department.name}" />
                        </p:column>
                        <p:column >
                            <f:facet name="header">
                                Qty
                            </f:facet>
                            <p:outputLabel value="#{bi.pharmaceuticalBillItem.qty}" />
                        </p:column>

                    </p:dataTable>
                </p:tab>

                <p:tab   title="Whole Sale"    >
                    <p:dataTable styleClass="noBorder" value="#{pharmacyController.institutionWholeSales}" var="ins">
                        <p:columnGroup type="header">
                            <p:row>
                                <p:column >
                                    <f:facet name="header">
                                        Department Name
                                    </f:facet>
                                </p:column>
                                <p:column >
                                    <f:facet name="header">
                                        QTY
                                    </f:facet>
                                </p:column>
                                <p:column >
                                    <f:facet name="header">
                                        Value
                                    </f:facet>
                                </p:column>
                            </p:row>
                        </p:columnGroup>
                        <p:subTable  value="#{ins.departmentSales}" var="dep">
                            <f:facet name="header">
                                #{ins.institution.name}
                            </f:facet>
                            <p:column>
                                #{dep.department.name}
                            </p:column>
                            <p:column style="text-align: right;">
                                <h:outputLabel value="#{dep.saleQty}">   
                                    <f:convertNumber integerOnly="true" />
                                </h:outputLabel> 
                            </p:column>
                            <p:column style="text-align: right;">
                                <h:outputLabel value="#{dep.saleValue}">  
                                    <f:convertNumber pattern="#,##0.00" />
                                </h:outputLabel> 
                            </p:column>
                            <p:columnGroup type="footer">
                                <p:row>
                                    <p:column footerText="Total "></p:column>
                                    <p:column style="text-align: right;" footerText="#{ins.institutionQty}">
                                        <f:facet name="footer">
                                            <h:outputLabel value="#{ins.institutionQty}">
                                                <f:convertNumber integerOnly="true" />
                                            </h:outputLabel>
                                        </f:facet>
                                    </p:column>
                                    <p:column style="text-align: right;" footerText="#{ins.institutionValue}">
                                        <f:facet name="footer">
                                            <h:outputLabel value="#{ins.institutionValue}">
                                                <f:convertNumber  pattern="#,##0.00" />
                                            </h:outputLabel>
                                        </f:facet>
                                    </p:column>
                                </p:row>
                            </p:columnGroup>
                        </p:subTable>  
                        <p:columnGroup type="footer">
                            <p:row>
                                <p:column>
                                    <f:facet name="footer">
                                        Total Institution
                                    </f:facet>
                                </p:column>
                                <p:column style="text-align: right;">
                                    <f:facet name="footer">
                                        <h:outputLabel  value="#{pharmacyController.grantWholeSaleQty}">   
                                            <f:convertNumber integerOnly="true" />
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>
                                <p:column style="text-align: right;">
                                    <f:facet name="footer">
                                        <h:outputLabel  value="#{pharmacyController.grantWholeSaleValue}">
                                            <f:convertNumber  pattern="#,##0.00" />
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>
                            </p:row>
                        </p:columnGroup>

                    </p:dataTable>                
                </p:tab>

                <p:tab   title="BHT ISSUE"    >
                    <p:dataTable styleClass="noBorder" value="#{pharmacyController.institutionBhtIssue}" var="ins">
                        <p:columnGroup type="header">
                            <p:row>
                                <p:column >
                                    <f:facet name="header">
                                        Department Name
                                    </f:facet>
                                </p:column>
                                <p:column >
                                    <f:facet name="header">
                                        QTY
                                    </f:facet>
                                </p:column>
                                <p:column >
                                    <f:facet name="header">
                                        Value
                                    </f:facet>
                                </p:column>
                            </p:row>
                        </p:columnGroup>
                        <p:subTable  value="#{ins.departmentSales}" var="dep">
                            <f:facet name="header">
                                #{ins.institution.name}
                            </f:facet>
                            <p:column>
                                #{dep.department.name}
                            </p:column>
                            <p:column style="text-align: right;">
                                <h:outputLabel value="#{dep.saleQty}">   
                                    <f:convertNumber integerOnly="true" />
                                </h:outputLabel> 
                            </p:column>
                            <p:column style="text-align: right;">
                                <h:outputLabel value="#{dep.saleValue}">  
                                    <f:convertNumber pattern="#,##0.00" />
                                </h:outputLabel> 
                            </p:column>
                            <p:columnGroup type="footer">
                                <p:row>
                                    <p:column footerText="Total "></p:column>
                                    <p:column style="text-align: right;" footerText="#{ins.institutionQty}">
                                        <f:facet name="footer">
                                            <h:outputLabel value="#{ins.institutionQty}">
                                                <f:convertNumber integerOnly="true" />
                                            </h:outputLabel>
                                        </f:facet>
                                    </p:column>
                                    <p:column style="text-align: right;" footerText="#{ins.institutionValue}">
                                        <f:facet name="footer">
                                            <h:outputLabel value="#{ins.institutionValue}">
                                                <f:convertNumber  pattern="#,##0.00" />
                                            </h:outputLabel>
                                        </f:facet>
                                    </p:column>
                                </p:row>
                            </p:columnGroup>
                        </p:subTable>  
                        <p:columnGroup type="footer">
                            <p:row>
                                <p:column>
                                    <f:facet name="footer">
                                        Total Institution
                                    </f:facet>
                                </p:column>
                                <p:column style="text-align: right;">
                                    <f:facet name="footer">
                                        <h:outputLabel  value="#{pharmacyController.grantBhtIssueQty}">   
                                            <f:convertNumber integerOnly="true" />
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>
                                <p:column style="text-align: right;">
                                    <f:facet name="footer">
                                        <h:outputLabel  value="#{pharmacyController.grantBhtValue}">
                                            <f:convertNumber  pattern="#,##0.00" />
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>
                            </p:row>
                        </p:columnGroup>

                    </p:dataTable>                
                </p:tab>

                <p:tab   title="Transfer Issue"    >
                    <p:dataTable styleClass="noBorder" id="trIssue" value="#{pharmacyController.institutionTransferIssue}" var="ins">
                        <p:columnGroup type="header">
                            <p:row>
                                <p:column >
                                    <f:facet name="header">
                                        To Department Name
                                    </f:facet>
                                </p:column>
                                <p:column >
                                    <f:facet name="header">
                                        Sent QTY
                                    </f:facet>
                                </p:column>
                                <p:column >
                                    <f:facet name="header">
                                        Sent Value
                                    </f:facet>
                                </p:column>
                            </p:row>
                        </p:columnGroup>
                        <p:subTable  value="#{ins.departmentSales}" var="dep">
                            <f:facet name="header">
                                #{ins.institution.name}
                            </f:facet>
                            <p:column>
                                #{dep.department.name}
                            </p:column>
                            <p:column style="text-align: right;">
                                <h:outputLabel value="#{dep.saleQtyAbs}">    
                                    <f:convertNumber integerOnly="true" />
                                </h:outputLabel> 
                            </p:column>
                            <p:column style="text-align: right;">
                                <h:outputLabel value="#{dep.saleValueAbs}">    
                                    <f:convertNumber  pattern="#,##0.00" />
                                </h:outputLabel> 
                            </p:column>
                            <p:columnGroup type="footer">
                                <p:row>
                                    <p:column footerText="Total "></p:column>
                                    <p:column style="text-align: right;" footerText="#{ins.institutionQty}">
                                        <f:facet name="footer">
                                            <h:outputLabel value="#{0-ins.institutionQty}">
                                                <f:convertNumber integerOnly="true" />
                                            </h:outputLabel>
                                        </f:facet>
                                    </p:column>
                                    <p:column style="text-align: right;" footerText="#{ins.institutionValue}">
                                        <f:facet name="footer">
                                            <h:outputLabel value="#{0-ins.institutionValue}">
                                                <f:convertNumber  pattern="#,##0.00" />
                                            </h:outputLabel>
                                        </f:facet>
                                    </p:column>
                                </p:row>
                            </p:columnGroup>
                        </p:subTable>  
                        <p:columnGroup type="footer">
                            <p:row>
                                <p:column>
                                    <f:facet name="footer">
                                        Total Institution
                                    </f:facet>
                                </p:column>
                                <p:column style="text-align: right;">
                                    <f:facet name="footer">
                                        <h:outputLabel  value="#{0-pharmacyController.grantTransferIssueQty}">
                                            <f:convertNumber integerOnly="true" />
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>
                                <p:column style="text-align: right;">
                                    <f:facet name="footer">
                                        <h:outputLabel  value="#{0-pharmacyController.grantTransferIssueValue}">
                                            <f:convertNumber  pattern="#,##0.00" />
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>
                            </p:row>
                        </p:columnGroup>

                    </p:dataTable>                
                </p:tab>

                <p:tab   title="Transfer Receive "    >
                    <p:dataTable styleClass="noBorder" id="trRceive" 
                                 value="#{pharmacyController.institutionTransferReceive}" var="ins">
                        <p:columnGroup type="header">
                            <p:row>
                                <p:column >
                                    <f:facet name="header">
                                        From Department Name
                                    </f:facet>
                                </p:column>
                                <p:column >
                                    <f:facet name="header">
                                        Received QTY
                                    </f:facet>
                                </p:column>
                                <p:column >
                                    <f:facet name="header">
                                        Received Value
                                    </f:facet>
                                </p:column>
                            </p:row>
                        </p:columnGroup>
                        <p:subTable  value="#{ins.departmentSales}" var="dep">
                            <f:facet name="header">
                                #{ins.institution.name}
                            </f:facet>
                            <p:column>
                                #{dep.department.name}
                            </p:column>
                            <p:column style="text-align: right;">
                                <h:outputLabel value="#{dep.saleQtyAbs}"> 
                                    <f:convertNumber integerOnly="true" />
                                </h:outputLabel> 
                            </p:column>
                            <p:column style="text-align: right;">
                                <h:outputLabel value="#{dep.saleValueAbs}"> 
                                    <f:convertNumber  pattern="#,##0.00" />
                                </h:outputLabel> 
                            </p:column>
                            <p:columnGroup type="footer">
                                <p:row>
                                    <p:column footerText="Total "></p:column>
                                    <p:column style="text-align: right;" footerText="#{0-ins.institutionQty}">
                                        <f:facet name="footer">
                                            <h:outputLabel value="#{0-ins.institutionQty}">
                                                <f:convertNumber integerOnly="true" />
                                            </h:outputLabel>
                                        </f:facet>
                                    </p:column>
                                    <p:column style="text-align: right;" footerText="#{0-ins.institutionValue}">
                                        <f:facet name="footer">
                                            <h:outputLabel value="#{0-ins.institutionValue}">
                                                <f:convertNumber  pattern="#,##0.00" />
                                            </h:outputLabel>
                                        </f:facet>
                                    </p:column>
                                </p:row>
                            </p:columnGroup>
                        </p:subTable>  
                        <p:columnGroup type="footer">
                            <p:row>
                                <p:column>
                                    <f:facet name="footer">
                                        Total Institution
                                    </f:facet>
                                </p:column>
                                <p:column style="text-align: right;">
                                    <f:facet name="footer">
                                        <h:outputLabel  value="#{0-pharmacyController.grantTransferReceiveQty}">
                                            <f:convertNumber integerOnly="true" />
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>
                                <p:column style="text-align: right;">
                                    <f:facet name="footer">
                                        <h:outputLabel  value="#{0-pharmacyController.grantTransferReceiveValue}">
                                            <f:convertNumber  pattern="#,##0.00" />
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>
                            </p:row>
                        </p:columnGroup>

                    </p:dataTable>                
                </p:tab>

                <p:tab   title="Department Issue"    >
                    <p:dataTable styleClass="noBorder" id="depIssue"
                                 value="#{pharmacyController.institutionIssue}" var="ins">
                        <p:columnGroup type="header">
                            <p:row>
                                <p:column >
                                    <f:facet name="header">
                                        To Department Name
                                    </f:facet>
                                </p:column>
                                <p:column >
                                    <f:facet name="header">
                                        Sent QTY
                                    </f:facet>
                                </p:column>
                                <p:column >
                                    <f:facet name="header">
                                        Sent Value
                                    </f:facet>
                                </p:column>
                            </p:row>
                        </p:columnGroup>
                        <p:subTable  value="#{ins.departmentSales}" var="dep">
                            <f:facet name="header">
                                #{ins.institution.name}
                            </f:facet>
                            <p:column>
                                #{dep.department.name}
                            </p:column>
                            <p:column style="text-align: right;">
                                <h:outputLabel value="#{dep.saleQtyAbs}">    
                                    <f:convertNumber integerOnly="true" />
                                </h:outputLabel> 
                            </p:column>
                            <p:column style="text-align: right;">
                                <h:outputLabel value="#{dep.saleValueAbs}">    
                                    <f:convertNumber  pattern="#,##0.00" />
                                </h:outputLabel> 
                            </p:column>
                            <p:columnGroup type="footer">
                                <p:row>
                                    <p:column footerText="Total "></p:column>
                                    <p:column style="text-align: right;" footerText="#{ins.institutionQty}">
                                        <f:facet name="footer">
                                            <h:outputLabel value="#{0-ins.institutionQty}">
                                                <f:convertNumber integerOnly="true" />
                                            </h:outputLabel>
                                        </f:facet>
                                    </p:column>
                                    <p:column style="text-align: right;" footerText="#{ins.institutionValue}">
                                        <f:facet name="footer">
                                            <h:outputLabel value="#{0-ins.institutionValue}">
                                                <f:convertNumber  pattern="#,##0.00" />
                                            </h:outputLabel>
                                        </f:facet>
                                    </p:column>
                                </p:row>
                            </p:columnGroup>
                        </p:subTable>  
                        <p:columnGroup type="footer">
                            <p:row>
                                <p:column>
                                    <f:facet name="footer">
                                        Total Institution
                                    </f:facet>
                                </p:column>
                                <p:column style="text-align: right;">
                                    <f:facet name="footer">
                                        <h:outputLabel  value="#{0-pharmacyController.grantIssueQty}">
                                            <f:convertNumber integerOnly="true" />
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>
                                <p:column style="text-align: right;">
                                    <f:facet name="footer">
                                        <h:outputLabel  value="#{0-pharmacyController.grantIssueValue}">
                                            <f:convertNumber  pattern="#,##0.00" />
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>
                            </p:row>
                        </p:columnGroup>

                    </p:dataTable>                
                </p:tab>

                <p:tab  title="GRN"  >

                    <p:dataTable styleClass="noBorder" id="grn" value="#{pharmacyController.grns}" 
                                 var="dd2" scrollable="true" scrollHeight="150" >
                        <p:column headerText="GRN No">
                            #{dd2.bill.deptId}
                        </p:column>
                        <p:column headerText="Department">
                            #{dd2.bill.department.name}
                        </p:column>
                        <p:column headerText="Date">
                            <h:outputLabel value="#{dd2.bill.createdAt}" >
                                <f:convertDateTime pattern="dd MMM yyyy" ></f:convertDateTime>
                            </h:outputLabel>
                        </p:column>
                        <p:column headerText="PO No">
                            #{dd2.bill.referenceBill.deptId}
                        </p:column>
                        <p:column headerText="Dealor">
                            #{dd2.bill.fromInstitution.name}
                        </p:column>
                        <p:column headerText="Qty">
                            #{dd2.qty}
                        </p:column>
                        <p:column headerText="Fr. Qty">
                            #{dd2.pharmaceuticalBillItem.freeQty}
                        </p:column>
                        <p:column headerText="Purchase Rate">
                            <h:outputLabel value="#{dd2.pharmaceuticalBillItem.purchaseRateInUnit}" ></h:outputLabel>
                        </p:column>
                        <p:column headerText="Sale Rate">
                            #{dd2.pharmaceuticalBillItem.retailRateInUnit}
                        </p:column>
                        <p:column headerText="Value">
                            <h:outputLabel value= "#{0-dd2.netValue}" ></h:outputLabel>
                        </p:column>
                    </p:dataTable>
                </p:tab>

                <p:tab  title="Purchase Orders"  >

                    <p:dataTable styleClass="noBorder" id="po" value="#{pharmacyController.pos}" var="dd3" scrollable="true" scrollHeight="150" >
                        <p:column headerText="Po No">
                            #{dd3.bill.deptId}
                        </p:column>
                        <p:column headerText="Order Date">
                            <p:outputLabel value="#{dd3.bill.createdAt}" >
                                <f:convertDateTime pattern="dd MMM yyyy"></f:convertDateTime>
                            </p:outputLabel>
                        </p:column>
                        <p:column headerText="Dealor">
                            #{dd3.bill.toInstitution.name}
                        </p:column>
                        <p:column headerText="PO Qty">
                            #{dd3.pharmaceuticalBillItem.qty}
                        </p:column>                           
                        <p:column headerText="Grn Qty">
                            #{dd3.totalGrnQty}
                        </p:column>                            
                    </p:dataTable>
                </p:tab>

                <p:tab  title="Direct Purchase"  >

                    <p:dataTable styleClass="noBorder" id="dp" value="#{pharmacyController.directPurchase}" var="dd3" scrollable="true" scrollHeight="150" >
                        <p:column headerText="Bill No">
                            #{dd3.bill.deptId}
                        </p:column>
                        <p:column headerText="Dealor">
                            #{dd3.bill.fromInstitution.name}
                        </p:column>
                        <p:column headerText="Billed By">
                            #{dd3.bill.creater.webUserPerson.name}
                        </p:column>    
                        <p:column headerText="Billed At">
                            <p:outputLabel value="#{dd3.bill.createdAt}" >
                                <f:convertDateTime pattern="dd MMM yyyy"></f:convertDateTime>
                            </p:outputLabel>
                        </p:column> 
                        <p:column headerText="Purchase Rate">
                            #{dd3.pharmaceuticalBillItem.purchaseRate}
                        </p:column>    
                        <p:column headerText="Sale Rate">
                            #{dd3.pharmaceuticalBillItem.retailRate}
                        </p:column>    
                        <p:column headerText="Purchase Qty">
                            #{dd3.pharmaceuticalBillItem.qty}
                        </p:column>    
                        <p:column headerText="Free Qty">
                            #{dd3.pharmaceuticalBillItem.freeQty}
                        </p:column>    
                        <p:column headerText="Purchase Value">
                            #{-dd3.netValue}
                        </p:column> 
                    </p:dataTable>
                </p:tab>
                <p:tab title="Packsizes" >
                    <p:dataTable value="#{pharmacyController.ampps}" var="p" >
                        <p:column>
                            <h:outputLabel value="#{p.name}" ></h:outputLabel>
                        </p:column>
                        <p:column>
                            <h:outputLabel value="#{p.dblValue}" ></h:outputLabel>
                        </p:column>

                    </p:dataTable>
                </p:tab>
            </p:tabView>
        </p:panel>

    </cc:implementation>
</html>